package model;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public  class CategoryItem extends BasicItem{
	private Set<Figure> figures;
	private Set<Color> colors;
	private Set<Size> sizes;
	
	CategoryItem(int id, String description, double price,
			double promotionalPrice, String brandDescription, Producer producer){
		super(id,description, price, promotionalPrice, brandDescription, producer);
		figures = new HashSet<Figure>();
		colors = new HashSet<Color>();
		sizes = new HashSet<Size>();
	}
	
	void addColor(Color color){
		colors.add(color);
	}
	void addFigure(Figure figure){
		figures.add(figure);
	}
	
	void addSize(Size size){
		sizes.add(size);
	}
	
	public Iterator<Color> getColors(){
		return colors.iterator();
	}
	
	public Iterator<Size> getSizes(){
		return sizes.iterator();
	}
	
	public Iterator<Figure> getFigures(){
		return figures.iterator();
	}
	
	@Override
	public String toString() {
		
		StringBuffer basicDescription = new StringBuffer(super.toString());
		basicDescription.append("\n");
		Iterator<Figure> itf = this.getFigures();
		Iterator<Color> itc = this.getColors();
		Iterator<Size> its = this.getSizes();
		StringBuffer figures = new StringBuffer();
		StringBuffer colors = new StringBuffer();
		StringBuffer sizes = new StringBuffer();
		while (itf.hasNext()){
			figures.append(itf.next().toString());
			figures.append("\n");
		}
		while(itc.hasNext()){
			colors.append(itc.next().toString());
			colors.append("\n");
		}
		while(its.hasNext()){
			sizes.append(its.next().toString());
			sizes.append("\n");
		}
		StringBuffer item = new StringBuffer();
		item.append(basicDescription);
		item.append(figures);
		item.append(colors);
		item.append(sizes);
		return item.toString();
	}
	
}
